Skip to content

Fix asan switch fiber with error stack info#2931

Merged
chenBright merged 3 commits intoapache:masterfrom
chenBright:fix_asan
Apr 2, 2025
Merged

Fix asan switch fiber with error stack info#2931
chenBright merged 3 commits intoapache:masterfrom
chenBright:fix_asan

Conversation

@chenBright
Copy link
Copy Markdown
Contributor

@chenBright chenBright commented Mar 31, 2025

What problem does this PR solve?

Issue Number:

Problem Summary:

#2890 调__sanitizer_start_switch_fiber时,应该传将要被调度的bthread stack信息,而不是将要挂起的bthread stack信息。

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@chenBright
Copy link
Copy Markdown
Contributor Author

chenBright commented Apr 1, 2025

CC @BusyJay

@wwbmmm
Copy link
Copy Markdown
Contributor

wwbmmm commented Apr 1, 2025

LGTM

@BusyJay
Copy link
Copy Markdown
Contributor

BusyJay commented Apr 1, 2025

需要在环境中显式设置 detect_stack_use_after_return=1 来验证 fake_stack 是否正确构建和析构吗?

@chenBright chenBright force-pushed the fix_asan branch 4 times, most recently from 2dbff8d to ccca039 Compare April 2, 2025 07:05
@chenBright chenBright changed the title Fix __sanitizer_start_switch_fiber with error stack info Fix asan switch fiber with error stack info Apr 2, 2025
@chenBright
Copy link
Copy Markdown
Contributor Author

chenBright commented Apr 2, 2025

需要在环境中显式设置 detect_stack_use_after_return=1 来验证 fake_stack 是否正确构建和析构吗?

@BusyJay UT设置了detect_stack_use_after_return=1,后续CI都会跑。

修复了另一个问题:bthread结束后,__sanitizer_start_switch_fiber(NULL)会删除fake stack,当前bthread栈不可用了。当下一个bthread复用栈,就会出现stack use after return的问题。

修复方案:bthread栈会复用,所以即使bthread结束了,也不调__sanitizer_start_switch_fiber(NULL),保证fake stack不会被删除。bthread栈在放回池时,会被poison,可以起到stack use after return类似的检查效果。

@BusyJay
Copy link
Copy Markdown
Contributor

BusyJay commented Apr 2, 2025

Cool, LGTM

@chenBright chenBright merged commit f44f803 into apache:master Apr 2, 2025
21 checks passed
@chenBright chenBright deleted the fix_asan branch April 2, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants